//
//  HMBaseTableViewVC.swift
//  swift一遍敲
//
//  Created by 刘耀宗 on 16/4/19.
//  Copyright © 2016年 刘耀宗. All rights reserved.
//

import UIKit

class HMBaseTableViewVC: UITableViewController,loadBaseViewDelegate {
    //登录
    let isLogin = HMUserAccessModel.shareAccessModel.login
    //
    //开始加载视图
    override func loadView() {
        if isLogin == true  {
            super.loadView()
        }
        else
        {
            self.view = baseView
        
        
        }
        
    }
    //加载视图完毕
    override func viewDidLoad() {
        super.viewDidLoad()
        setnagation()
        changeVC()
    }
    //代理方法
    func reginBtn() {
        print("点击了注册按钮")
    }
    func loginBtn() {
        let nava = UINavigationController.init(rootViewController: oauthrequest())
        self.presentViewController(nava, animated: true) {
              print("点击了登录按钮")
        }

      
    }
    private func setnagation()
    {
        //  public convenience init(title: String?, style: UIBarButtonItemStyle, target: AnyObject?, action: Selector)
     navigationItem.leftBarButtonItem = UIBarButtonItem(title: "取消",style: UIBarButtonItemStyle.Done, target: self,action: #selector(HMBaseTableViewVC.cancelClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "确定",style: UIBarButtonItemStyle.Done,target: self,action: #selector(HMBaseTableViewVC.doneClick))
        
        
    }
    //取消
   @objc private func cancelClick()
    {
    print("取消")
    
    }
    @objc private func doneClick()
    {
    
    print("确定")
    
    }
    //判断
    private func changeVC()
    {
        //判断vc
        //首页
        if self .isKindOfClass(HMHomeVC) {
            baseView.changeVC("tabbar_home", labelText: "关注一些人,回这里看看有什么惊喜 ", choose:true )
            baseView.startAnimation()
            
        }
            //发现
        else if self .isKindOfClass(HMDiscoverVC)
        {
             baseView.changeVC("tabbar_discover", labelText: "登录后,最新最热的微博尽在掌握 ", choose: false)
            
        }
            //消息
        else if self .isKindOfClass(HMMessageVC)
        {
            baseView.changeVC("tabbar_message_center", labelText: "登录后,别人评论你的微薄,发给你的消息都会在这里显示 ", choose: false)
            
        }
            //我的
        else if self .isKindOfClass(HMProfielVC)
        { baseView.changeVC("tabbar_profile", labelText: "登录后你的微博相册,个人资料,会显示在这里,展示给别人 ", choose: false)
            
            
        }
        
        
    }
    //懒加载
    private lazy var baseView: loadBaseView = {
     let baseView = loadBaseView()
        baseView.delegate = self
        return baseView
    }()

}
